<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
require_once __DIR__ . "/Common.php";
$ossClient = Common::getOssClient();
if(is_null($ossClient)) {
    exit(1);
}
$bucket = Common::getBucketName();
$ossClient->createBucket($bucket, OSS\OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket " . $bucket . " created");
$doesExist = $ossClient->doesBucketExist($bucket);
Common::println("bucket " . $bucket . " exist? " . ($doesExist ? "yes" : "no"));
$bucketListInfo = $ossClient->listBuckets();
$ossClient->putBucketAcl($bucket, OSS\OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
Common::println("bucket " . $bucket . " acl put");
$acl = $ossClient->getBucketAcl($bucket);
Common::println("bucket " . $bucket . " acl get: " . $acl);
createBucket($ossClient, $bucket);
doesBucketExist($ossClient, $bucket);
deleteBucket($ossClient, $bucket);
putBucketAcl($ossClient, $bucket);
getBucketAcl($ossClient, $bucket);
listBuckets($ossClient);
function createBucket($ossClient, $bucket)
{
    try {
        $ossClient->createBucket($bucket, OSS\OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE);
    } catch (OSS\Core\OssException $e) {
        printf("createBucket: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "createBucket: OK\n";
}
function doesBucketExist($ossClient, $bucket)
{
    try {
        $res = $ossClient->doesBucketExist($bucket);
    } catch (OSS\Core\OssException $e) {
        printf("doesBucketExist: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    if($res === true) {
        echo "doesBucketExist: OK\n";
    } else {
        echo "doesBucketExist: FAILED\n";
    }
}
function deleteBucket($ossClient, $bucket)
{
    try {
        $ossClient->deleteBucket($bucket);
    } catch (OSS\Core\OssException $e) {
        printf("deleteBucket: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "deleteBucket: OK\n";
}
function putBucketAcl($ossClient, $bucket)
{
    $acl = OSS\OssClient::OSS_ACL_TYPE_PRIVATE;
    try {
        $ossClient->putBucketAcl($bucket, $acl);
    } catch (OSS\Core\OssException $e) {
        printf("putBucketAcl: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "putBucketAcl: OK\n";
}
function getBucketAcl($ossClient, $bucket)
{
    try {
        $res = $ossClient->getBucketAcl($bucket);
    } catch (OSS\Core\OssException $e) {
        printf("getBucketAcl: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "getBucketAcl: OK\n";
    echo "acl: " . $res;
}
function listBuckets($ossClient)
{
    $bucketList = NULL;
    try {
        $bucketListInfo = $ossClient->listBuckets();
    } catch (OSS\Core\OssException $e) {
        printf("listBuckets: FAILED\n");
        printf($e->getMessage() . "\n");
        return NULL;
    }
    echo "listBuckets: OK\n";
    $bucketList = $bucketListInfo->getBucketList();
    foreach ($bucketList as $bucket) {
        echo $bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n";
    }
}

?>